package com.pc.admin.util;



import org.apache.commons.lang3.StringUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;


public class DateUtils extends DateFormatUtil {

    public static final String DATE_PATTERN = "yyyy-MM-dd";

    public static final String DATE_PATTERN1 = "yyyyMMddHHmmss";


    public static final String DATE_PATTERN_YMD = "yyyyMMdd";

    public static final String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
    public static final String DATE_PATTERN_MONTH_CH = "yyyy年MM月";

    public static String dateFormat(Date date, String pattern) {
        if (StringUtils.isBlank(pattern)) {
            pattern = DateUtils.DATE_PATTERN1;
        }
        if(Objects.isNull(date)){
            return null;
        }
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(date);
    }
}
